﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace T7task2
{
    public partial class Form1 : Form
    {
        DataTable dt = new DataTable();
        int i = 0;
        public Form1()
        {
            InitializeComponent();
        }

        private void splitContainer1_Panel1_Paint(object sender, PaintEventArgs e)
        {

        }

        private void Form1_Load(object sender, EventArgs e)
        {
            string sql = "select * from game";
            dt = DBHelper.dataTable(sql);
            dataGridView1.DataSource = dt;
        }

        private void bt_seach_Click(object sender, EventArgs e)
        {
            DataView dv = new DataView(dt);
            DataView ds = new DataView(dt);
            dv.RowFilter = string.Format("Gname  like '%{0}%'",textBox1.Text,textBox2.Text);
           // ds.RowFilter = string.Format("Gname  like '%{0}%'", textBox2.Text);
            dataGridView1.DataSource = dv;
            //dataGridView1.DataSource = ds;
        }

        private void bt_Asc_Click(object sender, EventArgs e)
        {
            DataView dv = new DataView(dt);
            dv.Sort = string.Format(" Gprice").ToString();
            dataGridView1.DataSource = dv;
        }

        private void bt_Desc_Click(object sender, EventArgs e)
        {
            DataView dv = new DataView(dt);
            dv.Sort = string.Format("Gstock desc").ToString();
            dataGridView1.DataSource = dv;
        }
    }
}
